home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- Droid NPC
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "npc_droid.h"
-
-
- static int sound_pain;
- static int sound_walk;
- static int sound_idle;
- static int sound_talk;
- static int sound_talk2;
- static int sound_sight;
- static int sound_search;
- static int sound_spark;
-
- void droid_standstill (edict_t *self);
- void droid_fidget (edict_t *self);
- void droid_damaged (edict_t *self);
-
- void droid_search (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
- }
-
- mframe_t droid_frames_stand [] =
- {
- ai_stand, 0, droid_fidget
- };
- mmove_t droid_move_stand = {FRAME_stand01, FRAME_stand01, droid_frames_stand, NULL};
-
- void droid_stand (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
- self->monsterinfo.currentmove = &droid_move_stand;
- }
-
- mframe_t droid_frames_fidget [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t droid_move_fidget = {FRAME_comm01, FRAME_comm20, droid_frames_fidget, droid_stand};
-
- void droid_fidget (edict_t *self)
- {
- if (self->spawnflags & 8) // don't want him to be at a console.
- return;
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- return;
- if (random() > 0.25)
- return;
-
- self->monsterinfo.currentmove = &droid_move_fidget;
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_IDLE, 0);
- }
-
- mframe_t droid_frames_still [] =
- {
-
- ai_still, 0, NULL
-
- };
- mmove_t droid_move_standstill = {FRAME_stand01, FRAME_stand01, droid_frames_still, droid_standstill};
-
- void droid_standstill (edict_t *self)
- {
- self->monsterinfo.currentmove = &droid_move_standstill;
- }
- void droid_step (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_walk, 1, ATTN_NORM, 0);
- }
- mframe_t droid_frames_walk [] =
- {
- ai_run, 1.0, droid_step,
- ai_run, 3.3, NULL,
- ai_run, 8.9, NULL,
- ai_run, 10.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 1.0, droid_step,
- ai_run, 3.0, NULL,
- ai_run, 8.0, NULL,
- ai_run, 10.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- };
- mmove_t droid_move_walk = {FRAME_walk01, FRAME_walk12, droid_frames_walk, NULL};
-
- void droid_walk (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- self->monsterinfo.currentmove = &droid_move_stand;
- else
- self->monsterinfo.currentmove = &droid_move_walk;
- }
-
- void droid_run_after_talk (edict_t *self)
- {
- self->monsterinfo.currentmove = &droid_move_walk;
- }
-
-
- void droidTalk (edict_t *self)
- {
- if (self->spawnflags & 1)
- gi.sound(self, CHAN_VOICE, sound_talk2, 1, ATTN_IDLE, 0);
- else
- gi.sound (self, CHAN_VOICE, sound_talk, 1, ATTN_IDLE, 0);
- }
-
- mframe_t droid_frames_talk [] =
- {
- ai_charge, 0, droidTalk
- };
- mmove_t droid_move_talk = {FRAME_stand01, FRAME_stand01, droid_frames_talk, droid_standstill};
-
- void droid_sight (edict_t *self, edict_t *other)
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- self->monsterinfo.currentmove = &droid_move_walk;
- }
-
- void droid_melee (edict_t *self)
- {
- self->monsterinfo.currentmove = &droid_move_talk;
- }
-
- void droid_dead (edict_t *self)
- {
- VectorSet (self->mins, -16, -16, 0);
- VectorSet (self->maxs, 16, 16, 24);
- self->movetype = MOVETYPE_TOSS;
- self->svflags |= SVF_DEADMONSTER;
- self->nextthink = 0;
- gi.linkentity (self);
- }
-
- void droid_spark(edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_spark, 1, ATTN_NORM, 0);
- }
-
- mframe_t droid_frames_damaged [] =
- {
- ai_move, 0, droid_spark,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, droid_spark,
- ai_move, 0, NULL,
- ai_move, 0, NULL
-
- };
- mmove_t droid_move_damaged = {FRAME_dama01, FRAME_dama06, droid_frames_damaged, droid_damaged};
-
- void droid_damaged (edict_t *self)
- {
- self->monsterinfo.aiflags = AI_RESURRECTING;
- M_SetEffects (self);
-
- self->monsterinfo.currentmove = &droid_move_damaged;
- }
-
- void droid_pain (edict_t *self, edict_t *other, float kick, int damage)
- {
- if (level.time < self->pain_debounce_time)
- return;
-
- self->pain_debounce_time = level.time + 3;
- gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_IDLE, 0);
-
- self->monsterinfo.aiflags = AI_RESURRECTING;
- M_SetEffects(self);
-
- self->monsterinfo.currentmove = &droid_move_damaged;
- }
-
- void droid_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- if (self->health <= self->gib_health)
- {
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (self->s.origin);
- gi.multicast (self->s.origin, MULTICAST_PVS);
- self->deadflag = DEAD_DEAD;
- G_FreeEdict (self);
- return;
- }
-
- if (self->deadflag == DEAD_DEAD)
- return;
-
- self->takedamage = DAMAGE_YES;
-
- self->monsterinfo.currentmove = &droid_move_damaged;
- }
-
-
- /*QUAKED monster_droid (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- void SP_npc_droid (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // pre-caches
- sound_pain = gi.soundindex ("droid/pain.wav");
- sound_idle = gi.soundindex ("droid/idle.wav");
- sound_talk = gi.soundindex ("droid/talk.wav");
- sound_talk2 = gi.soundindex ("droid/talk2.wav");
- sound_search = gi.soundindex ("droid/idle.wav");
- sound_sight = gi.soundindex ("droid/comm.wav");
- sound_spark = gi.soundindex ("droid/spark.wav");
- sound_walk = gi.soundindex ("droid/walk.wav");
-
- self->s.modelindex = gi.modelindex("models/npc/droid/tris.md2");
-
- VectorSet (self->mins, -16, -16, 0);
- VectorSet (self->maxs, 16, 16, 56);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
-
- self->classname = "npc_droid";
-
- self->max_health = 100;
- self->health = self->max_health;
- self->gib_health = 40;
- self->mass = 50;
-
- if (self->spawnflags & 16)
- {
- self->pain = droid_pain;
- self->die = droid_die;
- self->monsterinfo.stand = droid_damaged;
- self->monsterinfo.walk = droid_damaged;
- self->monsterinfo.run = droid_damaged;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = NULL;
- self->monsterinfo.melee = droid_damaged;
- self->monsterinfo.sight = NULL;
- self->monsterinfo.search = droid_damaged;
-
- self->monsterinfo.currentmove = &droid_move_damaged;
- self->monsterinfo.aiflags = AI_RESURRECTING;
- }
- else
- {
- self->pain = droid_pain;
- self->die = droid_die;
- self->monsterinfo.stand = droid_stand;
- self->monsterinfo.walk = droid_walk;
- self->monsterinfo.run = droid_walk;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = NULL;
- self->monsterinfo.melee = droid_melee;
- self->monsterinfo.sight = droid_sight;
- self->monsterinfo.search = droid_search;
-
- self->monsterinfo.currentmove = &droid_move_stand;
- }
-
- self->monsterinfo.scale = MODEL_SCALE;
-
- gi.linkentity (self);
-
- walkmonster_start (self);
- }
-